﻿using System;
using System.Collections.Generic;
using System.Text;
using Test.Data;

namespace Test.Examples {
	public class Example1 {
		public static readonly PackageProperty Prop = PackageProperty.Register("A", typeof(Int32), typeof(Example1));
		public Example1() {

			//Create base object
			DataBase data = new DataBase();
			data.Name = "Data Storage";
			data.UUID = Guid.NewGuid();
			data.Version = new Version(0, 0, 0, 1);
			data.SetValue(Prop, 233);
			//Shalow copy
			DataBase data2 = data.Clone() as DataBase;

			//Enumerate properties
			PackageProperty[] array = PackageProperty.GetProperties(typeof(DataBase));
			Console.WriteLine("Enumerating properties in: {0}", typeof(DataBase).Name);
			foreach (PackageProperty item in array) {
				Console.WriteLine("Owner: {0}\tName: {1}\tLocal Index:{2}\tType:{3}",item.OwnerType.FullName, item.Name, item.LocalIndex, item.PropertyType.Name);
			}
			Console.WriteLine();

			//Enumerate values
			Console.WriteLine("Enumerating values in: {0}", typeof(DataBase).Name);
			foreach (KeyValuePair<PackageProperty, Object> pair in data) {
				Console.WriteLine("Name: {0}\tValue:{1}", pair.Key, pair.Value);
			}
		}
	}
}
